package org.xdq.demo.url.view;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.xdq.demo.url.service.UrlService;

@Controller
public class ViewController {

    @Autowired
    private UrlService urlService;

    @GetMapping("/{url}")
    public String toUrlSrc(@PathVariable String url){
        String urlSrc = urlService.getUrlSrc(url);
        return "redirect:"+urlSrc;
    }
}
